package com.custom.tags;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import com.DAO.CategoryDAO;
import com.beans.CategoryForm;
import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List;

public class MenuTagHandler extends TagSupport {
    
    @Override
    public int doStartTag() throws JspException {
         
        try {
            //Get the writer object for output.
            JspWriter out = pageContext.getOut();
            
            CategoryDAO catDAO=new CategoryDAO();
            ArrayList<CategoryForm> catlist=catDAO.get();
                        
        
            
            out.print("<ul>");
            out.println("<li> <a href='homepage.jsp'> My Wall </a>  </li>");
            //out.println("<li> <a href='MyPostAction.do'> My Post </a>  </li>");
            for(CategoryForm cat:catlist){
            int id=cat.getCategoryId();	
            String name=cat.getName();            
            out.print("<li>");
            out.print("<a href='SelectCategoryAction.do?id="+id+"'>"+name+"</a>");
            out.print("</li>");
            }
           
            out.print("</ul>");           
 
        } catch (Exception e) {
            e.printStackTrace();
        }
        return SKIP_BODY;
    }
  
}
